package org.example.zzxsurprisemeal;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RestController
public class ResultrantCollor {

    @GetMapping("/restaurants")
    public List<Resultrant> getRestaurants(@RequestParam(value = "location", required = false) String location) {
        List<Resultrant> restaurants = new ArrayList<>();
        restaurants.add(new Resultrant("惊喜餐厅", "市中心", "特色美食"));
        // 添加更多餐厅到列表中...

        // 如果查询参数 location 存在，则过滤餐厅列表
        if (location != null && !location.isEmpty()) {
            restaurants.removeIf(resultrant -> !resultrant.getLocation().equals(location));
        }

        return restaurants;
    }
}

